<?php
namespace app\adminweb\controller;
class Pre extends \think\Controller
{
    //前初始化
    protected function initialize(){
        //验证登陆
        $data = input('param.');
        $url = $_SERVER['REMOTE_ADDR'];
        if ($url =='127.0.0.1')
            $data['token'] = '5259d09da04ffdc5031d151d685065fafe5da14b';

        $cacheInfo = cache($data['token']);
        $userInfo = \app\common\model\Account::where('telephone',$cacheInfo['telephone'])->find();
        //验证成功
        if ($cacheInfo['auth'] =='admin' && $userInfo){
            $this -> loginInfo = $userInfo;
            return true;
        }

        json([
            'code' => '400',
            'message' => '登陆已过期，请重新登陆'
        ])
            ->send();
        exit;

    }
}